const { Controller } = require('varal');
const { sequelize } = require('../../models');
const { QueryTypes } = require('sequelize');

class DocController extends Controller {
	async index() {
		const docService = this.app.service('DocService');
		const { category_id } = this.app.fields;
		const where = {}
		if (category_id > 0) where.category_id = category_id;

		const { data } = await docService.get(where, 1, 10);

		this.app.json({
			err_code: 0,
			data
		})
	}

	async category() {
		const dictService = this.app.service('DictionaryService');
		const data = await dictService.get({ root_code: 'DOC_CATEGORY' }, 1, 20);

		this.app.json({
			err_code: 0,
			data
		})
	}
}

exports = module.exports = DocController;